package wineshop.domain.market;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import wineshop.domain.general.Address;
import wineshop.domain.general.Country;

public class ItemTest {
	Seller laVersa;
	Product product;
	Address address;

	@Before
	public void setUp() {
		Country italy = new Country("Italy");
		Address addressLaVersa = new Address("Via F.Crispi", "15",
				"Santa Maria della Versa", "27047", italy);
		laVersa = new Seller("La Versa", addressLaVersa);
		product = new Product("Spumante", "Italian dessert wine.", "white", 75,
				12.0);
		address = addressLaVersa;
	}

	@Test
	public void shouldNewCreatedItemBeNotSold() {
		Item wine = laVersa.makeNewItem(product, "ABC", 1000, 2006);

		assertFalse(wine.isSold());
	}

	@Test
	public void shouldBoughtItemBeSold() {
		Item wine = laVersa.makeNewItem(product, "ABC", 1000, 2006);
		laVersa.changeAvailability(true, wine);
		Customer customer = new Customer("tom", "jones", "tjones");
		laVersa.sell(wine, customer, new Creditcard("123", customer), address);

		assertTrue(wine.isSold());
	}

	@After
	public void tearDown() {
		laVersa = null;
		product = null;
		address = null;
	}
}
